@extends('layouts.admin')
@section('style')
    <style type="text/css">
        .layui-table thead th{  text-align: center;}
        .layui-table .layui-form-item{  margin-bottom: 2px;  }
        .layui-table .layui-form-item .layui-input-inline{  width:auto!important;  float:none;  }
     </style>
@endsection
@section('content')
    <div class="admin_main">
        <div class="admin_header_fixed">
            <div class="admin_header clearfix">
                <div class="title"><i></i>黑名单列表</div>
                <div class="action">
                    <b></b>
                    <div class="layui-btn-group ">
                        <a class="layui-btn layui-btn-primary layui-btn-small create javascript" rel="addAccount" data-title="新增账号"
                           data-icon="fa-plus-circle" href="{{ url('account/create') }}"><i class="fa fa-plus-circle"></i> 新增</a>
                    </div>
                </div>
            </div>
        </div>
        <div class="admin_base">
            <div class="admin_module clearfix admin_module_search">
                <i class="line"></i>
                <a class="javascript" id="list_search_toggle" data-search-box="list_search" rel='list_search_switch'>关闭搜索</a>
                <div id="list_search" class="clearfix">
                    <form action="{{ url('account/blacklist') }}" id="ListForm" class="layui-form layui-form-pane"
                          novalidate="1">
                        <div clss="layui-inline">
                            <div class="layui-form-item">
                                <div class="layui-input-inline" style="width:100px;">
                                    <select name="opt_type">
                                        <option value="user_id" @if($opt_type=='user_id') selected @endif >操作员ID</option>
                                        <option value="username" @if($opt_type=='username') selected @endif >操作员</option>
                                        <option value="account_no" @if($opt_type=='account_no') selected @endif >旺旺号</option>
                                    </select>
                                </div>
                                <div class="layui-input-inline">
                                    <input type="text" name="keywords" value="{{ $keywords }}" id="keywords"
                                           placeholder="请填写关键词" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-inline">
                                    <button class="layui-btn" lay-submit lay-filter="btn_query">查询</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="box_list">
                <div class="box_content">
                    <form method="post" action="" id="list_form" class="layui-form" novalidate="1">
                        {{ csrf_field() }}
                        <table class="layui-table list" lay-skin="line" lay-even="true" lay-filter="list">
                            <colgroup>
                                <col width="150px"/>
                                <col width="150px"/>
                                <col width="150px"/>
                                <col width=""/>
                                <col width="80px"/>
                            </colgroup>
                            <thead>
                                <tr>
                                    <th>时间</th>
                                    <th>账号</th>
                                    <th>操作员</th>
                                    <th>备注</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach($datas as $data)
                                    <tr>
                                        <td>{{ $data->created_at }}</td>
                                        <td>{{ $data->account_no }}</td>
                                        <td>[{{ $data->user_id }}]{{ !is_null($data->user)?$data->user->nickname:'' }}</td>
                                        <td title="{{ $data->comm }}">{{ str_limit($data->comm,50) }}</td>
                                        <td class="item_action">
                                            <div class="layui-table-cell">
                                                <a href="{{ url('account/'.$data->id) }}" data-confirm="<font color=red>相关信息一并删除且不能恢复，是否继续?</font>" class="layui-btn layui-btn-danger  layui-btn-xs J-item-delete" title="删除" >删除</a>
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </form>
                </div>
                <div class="page-box">
                    <div id="pageShow"></div>
                </div>
            </div>
        </div>
    </div>
@endsection
@section('script')
    <script type="text/javascript">
        var layForm;
        var count = parseInt("{{ $counts }}");
        var limit = parseInt("{{ $limit }}");
        var currPage = parseInt("{{ $page }}");
        var addAccount = null;
        layui.use(['form', 'element', 'layer', 'utils', 'xmPage'], function () {
            layForm = layui.form;
            var URL = layui.utils.URL;

            if (count > 0) {
                var xmPage = layui.xmPage({
                    formElem: '#ListForm',
                    limit: limit,
                    count: count,
                    curr: currPage,
                    layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'],
                    prev: '<i class="fa fa-arrow-left"></i>',
                    next: '<i class="fa fa-arrow-right"></i>',
                });
                xmPage.render();
            }

            layForm.on('submit(btn_query)', function (data) {
                $("#page").val(1);
                $(data.form).submit();
            })
            addAccount = function() {
                var url = $(this).attr('href');
                var current_document = document;
                if(parent.layer){
                    var Layer = parent.layer;
                }else{
                    var Layer = layer;
                }
                Layer.open({
                    type: 2,
                    title: '新增黑名单',
                    content: url,
                    resize: false,
                    area: ['600px', '300px'],
                    btn: ['确定', '取消'],
                    yes: function (index, layero) {
                        var contentWindow = $(layero).find('iframe')[0].contentWindow;
                         contentWindow.doSubmit(function () {
                            document.location.reload();
                            Layer.closeAll();
                        });
                    }
                })
            }
        });
    </script>
@endsection